package org.smart4j.chapter2.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.smart4j.chapter2.helper.DatabaseHelper;
import org.smart4j.chapter2.model.Customer;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

//提供客户数据服务
public class CustomerService {

    private static final Logger LOGGER = LoggerFactory.getLogger(CustomerService.class);

    /*获取客户列表*/
    public List<Customer> getCustomerList(){
        String sql = "select * from customer";
        return DatabaseHelper.queryEntityList(Customer.class, sql);
    }

    //获取客户
    public Customer getCustomer(long id){

        return null;
    }

    //创建客户
    public boolean createCustomer(Map<String,Object> fileMap){
        return DatabaseHelper.insertEntity(Customer.class,fileMap);
    }

    //更新客户
    public boolean updateCustomer(long id, Map<String,Object> fileMap){
        return DatabaseHelper.updateEntity(Customer.class, id, fileMap);
    }

    //删除客户
    public boolean deleteCustomer(long id){
        return false;
    }
}
